#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# @property 装饰器把一个方法变成属性调用

class Screen(object):

    @property
    def width(self):
        return self._width
    
    @width.setter
    def width(self, w):
        if not isinstance(w, int):
            raise ValueError('width should be a int')
        self._width = w

    @property
    def height(self):
        return self._height

    @height.setter
    def height(self, h):
        if not isinstance(h, int):
            raise ValueError('height should be a int')
        self._height = h

    @property
    def resolution(self):
        return self._width * self._height


s = Screen()
s.width = 1024
s.height = 768
print(s.resolution)